home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
hex.inc
< prev
next >
Wrap
Text File
|
1985-06-03
|
640b
|
28 lines
TYPE str4 = STRING[5];
FUNCTION hex(dec:INTEGER):str4;
CONST
chs : ARRAY [0..15] OF CHAR = '0123456789ABCDEF';
VAR
p,q :INTEGER;
rslt :str4;
BEGIN
IF dec < 0 THEN
BEGIN
dec := dec + 32767;
dec := dec + 1;
p := 8 + dec DIV 4096;
END
ELSE p := dec DIV 4096;
rslt := '$'+chs[p];
dec := dec MOD 4096;
p := dec DIV 256;
rslt := rslt + chs[p];
dec := dec MOD 256;
rslt := rslt + chs[dec DIV 16];
dec := dec MOD 16;
rslt := rslt + chs[dec];
hex := rslt;
END;